using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using DAL;
using Utility;

public partial class Admin_doanhnghiepsua : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            LoadData();
        }
    }

    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbdoanhnghiepDTO dn = tbdoanhnghiepBUS.GetByID(id);
            if (dn != null)
            {

                lt_madn.Text = dn.Madn.ToString();                
                txt_diachi.Text = dn.Diachi;
                txt_tendn.Text = dn.Tendn;
                txt_dienthoai.Text = dn.Dienthoai;
                txt_taikhoan.Text = dn.Taikhoan;
                txt_matkhau.Text = dn.Matkhau;



            }
        }
        catch
        {
            Response.Redirect("doanhnghieplist.aspx");
        }
    }
    protected void btn_Update_Click(object sender, EventArgs e)
    {
        try
        {
            tbdoanhnghiepDTO dn = new tbdoanhnghiepDTO();
            dn.Madn = int.Parse(lt_madn.Text);
            dn.Tendn = txt_tendn.Text;
            dn.Diachi = txt_diachi.Text;
            dn.Dienthoai = txt_dienthoai.Text;
            dn.Taikhoan = txt_taikhoan.Text;
            dn.Matkhau = txt_matkhau.Text;


            tbdoanhnghiepBUS.Update(dn);
            Response.Redirect("doanhnghieplist.aspx");
            Label_thanhcong.Text = tbdoanhnghiepBUS.error;
        }

        catch
        {
            Label_thanhcong.Text = tbdoanhnghiepBUS.error;
            Response.Redirect("doanhnghieplist.aspx");
        }
    }
}
